// var express = require('express');
import express from 'express';

import User from '../../entity/system/User';
import UserService from '../../service/system/UserService';
import BaseEntityContorller from '../BaseEditController';

/**
 * 用户的接口
 */
export class UserController extends BaseEntityContorller<User> {
    constructor() {
        super(new UserService());
    }
    protected validate(data: User): boolean {
        if (!data.account) {
            return false;
        }
        if (!data.name) {
            return false;
        }
        return true;
    }
    protected newInstance(): User {
        return new User();
    }
}

var router = express.Router();
const userController = new UserController();

//获取
router.get('/get', userController.get.bind(userController));
//保存
router.post('/save', userController.save.bind(userController));
//更新
router.post('/update', userController.update.bind(userController));
//删除
router.get('/delete', userController.deleteData.bind(userController));

// module.exports = router;
export default router;
